<?php

namespace App\Http\Controllers;

use App\Traits\JwtClaims;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests, \Dingo\Api\Routing\Helpers, JwtClaims;

    /**
     * 返回成功消息
     * @param array $data
     * @param int $status_code 需要返回的参数
     * @param string $message
     * @return mixed
     */
    protected function success($data = [], $message = '请求成功')
    {
        return $this->response->array([
            'code' => 0,
            'message' => $message,
            'data' => $data
        ]);
    }

    /**
     * 返回HTTP请求错误消息
     * @param string $message
     * @param int $status_code
     */
    protected function error($message = 'This is an error...', $status_code = 404)
    {
        $this->response->error($message, $status_code);
    }

}
